import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:flutter/material.dart';

class colorPicker extends StatefulWidget {

  @override
  State<StatefulWidget> createState() => _ColorPickerState();
}

class _ColorPickerState extends State<colorPicker> {


  // create some values
  Color pickerColor = Color(0xff443a49);
  Color currentColor = Color(0xff443a49);

// ValueChanged<Color> callback
  void changeColor(Color color) {
    setState(() => pickerColor = color);
  }
  List<Color> currentColors = [Colors.limeAccent, Colors.green];
// raise the [showDialog] widget
  void changeColors(List<Color> colors) => setState(() => currentColors = colors);


  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        ColorsPick()
      ],
    );
  }
  ColorsPick(){
   return showDialog(
      context: context,
      builder: (context) {
        return AlertDialog(
          title: const Text('选择灯带颜色！'),
          content: SingleChildScrollView(
            // child: ColorPicker(
            //   pickerColor: pickerColor,
            //   onColorChanged: changeColor,
            //   showLabel: true,
            //   pickerAreaHeightPercent: 0.8,
            // ),
            // Use Material color picker:
            //
            // child: MaterialPicker(
            //   pickerColor: pickerColor,
            //   onColorChanged: changeColor,
            //   enableLabel: true,
            // ),
            //
            // Use Block color picker:
            //
            // child: BlockPicker(
            //   pickerColor: currentColor,
            //   onColorChanged: changeColor,
            // ),
            //
            child: MultipleChoiceBlockPicker(
              pickerColors: currentColors,
              onColorsChanged: changeColors,
            ),
          ),
          actions: <Widget>[
            FlatButton(
              child: const Text('确定'),
              onPressed: () {
                setState(() => currentColor = pickerColor);
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }

}
